package osk.biz;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class SubcategoryDAO extends DataAccessObject{
	String getSubcategoryList = "select * from sub_category where category_id = ?";
	
	public SubcategoryDAO(){
		super();
	}
	
	public List<SubcategoryDTO> getSubcategoryList(SubcategoryDTO dto){
		List<SubcategoryDTO> subcategoryList = new ArrayList<SubcategoryDTO>();
		try {
			stmt = conn.prepareStatement(getSubcategoryList);
			stmt.setInt(1, dto.getCategory_id());
			
			rs = stmt.executeQuery();
			while(rs.next()){
				SubcategoryDTO vo = new SubcategoryDTO();
				vo.setName(rs.getString("subcategory_name"));
				
				System.out.println(vo.name);				
				subcategoryList.add(vo);
			}
			
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			JDBCUtil.close(rs, stmt, conn);
		}
		return subcategoryList;
	}
}
